-- @owner: @zhanghuan96
-- @date: 2024/12/16
-- @testpoint: gms_utility.exec_ddl_statement，语句为创建、修改、删除存储过程，部分合理报错
@conn PrimaryDbAmode;
--前置条件
drop extension if exists gms_utility cascade;
create extension gms_utility;
set behavior_compat_options='bind_procedure_searchpath','plpgsql_dependency';
--step1:自定义函数中建表;expect:成功
drop TABLE if exists t_ddl0015;
call gms_utility.exec_ddl_statement('CREATE OR REPLACE PROCEDURE public.create_employee_table()
LANGUAGE plpgsql
AS $$
BEGIN
    EXECUTE ''CREATE TABLE t_ddl0015 (
        id SERIAL PRIMARY KEY,
        name VARCHAR(100) NOT NULL,
        salary NUMERIC(10, 2) NOT NULL
    )'';
END;
$$;');
--step2:exec_ddl_statement语句为执行存储过程;expect:报错
call gms_utility.exec_ddl_statement('call public.create_employee_table()');
--step3:调用存储过程;expect:成功
call public.create_employee_table();
--step4:修改存储过程名称;expect:成功
call gms_utility.exec_ddl_statement('ALTER procedure public.create_employee_table() rename to create_employee_table_new');
--step5:重编译存储过程;expect:成功
call gms_utility.exec_ddl_statement('ALTER procedure public.create_employee_table_new compile;');
--step6:删除存储过程;expect:成功
call gms_utility.exec_ddl_statement('drop procedure public.create_employee_table_new');
--step7:清理环境;expect:成功
drop table public.t_ddl0015;
drop extension if exists gms_utility cascade;
reset behavior_compat_options;